-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[incubator-kie-drools-5792] [new-parser] improve drools-drl-parser-tests #5855
[incubator-kie-drools-5792] [new-parser] improve drools-drl-parser-tests #5855
Conversation
…stsa to test with old and new parsers - Old and new parser coverage using 2 surefire test executions - Fixed Descr common property issues to keep backward compatibility - A few test cases remaining without backward compatibility ("Backward Compatibility Notes" left) because the old parser seems to be wrong. - A few expr test cases remaining without backward compatibility ("Backward Compatibility Notes" left). Error code/message don't seem to be important. Also the new parser ones are better.
d3ec507
to
e75d0d6
Compare
<execution> | ||
<!-- override default-test for new parser --> | ||
<id>default-test</id> | ||
<configuration> | ||
<systemPropertyVariables> | ||
<drools.drl.antlr4.parser.enabled>true</drools.drl.antlr4.parser.enabled> | ||
</systemPropertyVariables> | ||
</configuration> | ||
</execution> | ||
<execution> | ||
<id>old-parser-test</id> | ||
<configuration> | ||
<systemPropertyVariables> | ||
<drools.drl.antlr4.parser.enabled>false</drools.drl.antlr4.parser.enabled> | ||
</systemPropertyVariables> | ||
</configuration> | ||
<goals> | ||
<goal>test</goal> | ||
</goals> | ||
</execution> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now we can run old and new parser for the drools-drl-parser-tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if I understand. Does this run the new tests (that we keep on adding to on this feature branch) against both the new and the old parser?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yurloc Yes, in drools-drl-parser-tests
, surefire runs twice with drools.drl.antlr4.parser.enabled
= true
and false
. You would see:
[INFO] --- surefire:3.1.2:test (default-test) @ drools-drl-parser-tests ---
[INFO] Using auto detected provider org.apache.maven.surefire.junitplatform.JUnitPlatformProvider
[INFO]
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running org.drools.drl.parser.antlr4.DRLExprParserTest
...
### parse : ANTLR4_PARSER_ENABLED = true
### parse : ANTLR4_PARSER_ENABLED = true
...
[INFO]
[INFO] Results:
[INFO]
[WARNING] Tests run: 351, Failures: 0, Errors: 0, Skipped: 17
[INFO]
[INFO]
[INFO] --- surefire:3.1.2:test (old-parser-test) @ drools-drl-parser-tests ---
[INFO] Using auto detected provider org.apache.maven.surefire.junitplatform.JUnitPlatformProvider
[INFO]
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running org.drools.drl.parser.antlr4.DRLExprParserTest
...
### parse : ANTLR4_PARSER_ENABLED = false
### parse : ANTLR4_PARSER_ENABLED = false
...
[INFO]
[INFO] Results:
[INFO]
[WARNING] Tests run: 351, Failures: 0, Errors: 0, Skipped: 17
// Backward Compatibility Notes: | ||
// Antlr4 gives a different error code/message from antlr3 for this case. | ||
// Backward compatibility doesn't seem to be required in this case. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I leave Backward Compatibility Notes
when test results are different between old and new parser. We can categorize the cases into:
A) The difference comes from Antrl3 and 4, so we cannot change.
B) Old parser seems to be wrong and if we mimic the old behaviour, it would get unnecessarily complex. -> but, of course, we can discuss and look for compromise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please give us one or more examples of B)? In which cases the old parser is wrong? This would help us to focus this discussion and decide if it makes sense to pollute the new parser to accommodate the weird behaviors of the old one (I hope not).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mariofusco Sure, commented below. Probably it's easier to look in https://github.com/apache/incubator-kie-drools/pull/5855/files
/** | ||
* Determine if the current token is the end of a RHS DRL by lookahead. | ||
* 1. 'end' | ||
* 2. skip semi, WS, and comment | ||
* 3. next token should be EOF or statement or attribute keyword | ||
* | ||
* TODO: This method is low-level and may be too complex in order to keep backward compatibility. | ||
* This could be refactored by going back to a parser rather than the lexer island mode. | ||
*/ | ||
boolean isRhsDrlEnd() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isRhsDrlEnd
is required because we use lexer island mode and end
has a tricky condition (to meet backward compatibility) for a semantic predicate. This method is low-level and too complex. I filed #5856 to investigate a better approach.
@yurloc @gitgabrio @mariofusco Please review, thanks! |
// Backward Compatibility Notes: | ||
// Old expr parser (DRL6Expressions) allows this expression because it's too tolerant (fail at runtime anyway). | ||
// Backward compatibility doesn't seem to be required in this case. (But we may align with the old tolerant behavior.) | ||
if (DrlParser.ANTLR4_PARSER_ENABLED) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Backward Compatibility Notes
: B) Old parser seems to be wrong
Old parser allows x.int
.
// Backward Compatibility Notes: | ||
// The old DRL6Parser uses only the attribute value token for common properties (seem to be wrong), so startCharacter and column are different between old and new parser. | ||
// Backward compatibility doesn't seem to be required in this case. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Backward Compatibility Notes
: B) Old parser seems to be wrong
For TypeFieldDescr name : String
,
Old parser handles only String
for common properties. So startCharacter
is the position of S
New parser handles the whole expression (like other Descr), so startCharacter
is the position of n
// Backward Compatibility Notes: | ||
// The old DRL6Parser uses only the attribute value token for common properties (seem to be wrong), so startCharacter and column are different between old and new parser. | ||
// Backward compatibility doesn't seem to be required in this case. (If do it, the code would be unnecessarily complicated.) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Backward Compatibility Notes
: B) Old parser seems to be wrong
For AttributeDescr salience 42
,
Old parser handles only 42
for common properties. So startCharacter
is the position of 4
New parser handles the whole expression (like other Descr), so startCharacter
is the position of s
// Backward Compatibility Notes: | ||
// The old DRL6Parser doesn't populate common properties of FromDescr (seem to be wrong). | ||
// Backward compatibility doesn't seem to be required in this case. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Backward Compatibility Notes
: B) Old parser seems to be wrong
Old parser doesn't populate FromDescr common properties. So all -1
.
// Backward Compatibility Notes: | ||
// The old DRL6Parser doesn't populate common properties of EntryPointDescr (seem to be wrong). | ||
// Backward compatibility doesn't seem to be required in this case. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Backward Compatibility Notes
: B) Old parser seems to be wrong
Old parser doesn't populate EntryPointDescr common properties. So all -1
.
// Backward Compatibility Notes: | ||
// The old DRL6Parser doesn't populate common properties of WindowReferenceDescr (seem to be wrong). | ||
// Backward compatibility doesn't seem to be required in this case. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Backward Compatibility Notes
: B) Old parser seems to be wrong
Old parser doesn't populate WindowReferenceDescr common properties. So all -1
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
drools-drl/drools-drl-parser/src/main/java/org/drools/drl/parser/antlr4/LexerHelper.java
Outdated
Show resolved
Hide resolved
<execution> | ||
<!-- override default-test for new parser --> | ||
<id>default-test</id> | ||
<configuration> | ||
<systemPropertyVariables> | ||
<drools.drl.antlr4.parser.enabled>true</drools.drl.antlr4.parser.enabled> | ||
</systemPropertyVariables> | ||
</configuration> | ||
</execution> | ||
<execution> | ||
<id>old-parser-test</id> | ||
<configuration> | ||
<systemPropertyVariables> | ||
<drools.drl.antlr4.parser.enabled>false</drools.drl.antlr4.parser.enabled> | ||
</systemPropertyVariables> | ||
</configuration> | ||
<goals> | ||
<goal>test</goal> | ||
</goals> | ||
</execution> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if I understand. Does this run the new tests (that we keep on adding to on this feature branch) against both the new and the old parser?
...ols-drl-parser-tests/src/test/java/org/drools/drl/parser/antlr4/DescrCommonPropertyTest.java
Show resolved
Hide resolved
final RuleDescr rule = pkg.getRules().get(0); | ||
AndDescr and = rule.getLhs(); | ||
assertProperties(and, 21, 87, 3, 6, 3, 72); | ||
assertProperties(and, 19, 90, 3, 4, 3, 74); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the record, I checked this one and the new numbers are correct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, previously, it didn't include surrounding parentheses.
…er/antlr4/LexerHelper.java Co-authored-by: Jiří Locker <[email protected]>
…sts (apache#5855) * [incubator-kie-drools-5854] [new-parser] improve drools-drl-parser-testsa to test with old and new parsers - Old and new parser coverage using 2 surefire test executions - Fixed Descr common property issues to keep backward compatibility - A few test cases remaining without backward compatibility ("Backward Compatibility Notes" left) because the old parser seems to be wrong. - A few expr test cases remaining without backward compatibility ("Backward Compatibility Notes" left). Error code/message don't seem to be important. Also the new parser ones are better. * Update drools-drl/drools-drl-parser/src/main/java/org/drools/drl/parser/antlr4/LexerHelper.java Co-authored-by: Jiří Locker <[email protected]> * - removed unused import --------- Co-authored-by: Jiří Locker <[email protected]>
…sts (apache#5855) * [incubator-kie-drools-5854] [new-parser] improve drools-drl-parser-testsa to test with old and new parsers - Old and new parser coverage using 2 surefire test executions - Fixed Descr common property issues to keep backward compatibility - A few test cases remaining without backward compatibility ("Backward Compatibility Notes" left) because the old parser seems to be wrong. - A few expr test cases remaining without backward compatibility ("Backward Compatibility Notes" left). Error code/message don't seem to be important. Also the new parser ones are better. * Update drools-drl/drools-drl-parser/src/main/java/org/drools/drl/parser/antlr4/LexerHelper.java Co-authored-by: Jiří Locker <[email protected]> * - removed unused import --------- Co-authored-by: Jiří Locker <[email protected]>
…sts (apache#5855) * [incubator-kie-drools-5854] [new-parser] improve drools-drl-parser-testsa to test with old and new parsers - Old and new parser coverage using 2 surefire test executions - Fixed Descr common property issues to keep backward compatibility - A few test cases remaining without backward compatibility ("Backward Compatibility Notes" left) because the old parser seems to be wrong. - A few expr test cases remaining without backward compatibility ("Backward Compatibility Notes" left). Error code/message don't seem to be important. Also the new parser ones are better. * Update drools-drl/drools-drl-parser/src/main/java/org/drools/drl/parser/antlr4/LexerHelper.java Co-authored-by: Jiří Locker <[email protected]> * - removed unused import --------- Co-authored-by: Jiří Locker <[email protected]>
…sts (#5855) * [incubator-kie-drools-5854] [new-parser] improve drools-drl-parser-testsa to test with old and new parsers - Old and new parser coverage using 2 surefire test executions - Fixed Descr common property issues to keep backward compatibility - A few test cases remaining without backward compatibility ("Backward Compatibility Notes" left) because the old parser seems to be wrong. - A few expr test cases remaining without backward compatibility ("Backward Compatibility Notes" left). Error code/message don't seem to be important. Also the new parser ones are better. * Update drools-drl/drools-drl-parser/src/main/java/org/drools/drl/parser/antlr4/LexerHelper.java Co-authored-by: Jiří Locker <[email protected]> * - removed unused import --------- Co-authored-by: Jiří Locker <[email protected]>
…sts (apache#5855) * [incubator-kie-drools-5854] [new-parser] improve drools-drl-parser-testsa to test with old and new parsers - Old and new parser coverage using 2 surefire test executions - Fixed Descr common property issues to keep backward compatibility - A few test cases remaining without backward compatibility ("Backward Compatibility Notes" left) because the old parser seems to be wrong. - A few expr test cases remaining without backward compatibility ("Backward Compatibility Notes" left). Error code/message don't seem to be important. Also the new parser ones are better. * Update drools-drl/drools-drl-parser/src/main/java/org/drools/drl/parser/antlr4/LexerHelper.java Co-authored-by: Jiří Locker <[email protected]> * - removed unused import --------- Co-authored-by: Jiří Locker <[email protected]>
Issue:
Before PR in
drools-model-codegen
After PR in
drools-model-codegen